<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ECSHOP 管理中心 - 添加部门</title>
<meta name="robots" content="noindex, nofollow" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- 引入公共页面 -->
<jsp:include page="/WEB-INF/views/common.jsp"></jsp:include>
<script language="javascript">
	
	//修改表单提交地址
	function changForm(){
		
		//1、先获取表单对象
		var frm=document.forms[0];
		//2、修改表单的action属性
		//判断:如果id的值为空是添加，否则是编辑
		var id=document.getElementById("employee.id").value;
		if (id == "") {
			frm.action="${path }/emp_save.action";
		} else {
			frm.action="${path }/emp_update.action";
		}
		
		//3、提交
		frm.submit();
	}
	
</script>
</head>
<body>
	<h1>
		<span class="action-span"><a href="${path}/emp_viewEdit.action">添加新员工</a> </span>
		<span class="action-span1"><a href="__GROUP__">ECSHOP 管理中心</a> </span> 
		<span id="search_id" class="action-span1"> - 员工列表</span>
		<!-- 		<div style="clear:both"></div> -->
	</h1>
	<div class="main-div">
		<form action="${path}/emp_save.action" method="post">
			<!-- 隐藏域修改id的值(编辑的时候用) -->
			<s:hidden name="employee.id" id="employee.id" value="%{employee.id}"></s:hidden>

			<table width="100%" id="general-table">
				<tr>
					<td class="label">姓名:</td>
					<td><s:textfield name="employee.name"></s:textfield></td>
				</tr>
				<tr>
					<td class="label">真实姓名:</td>
					<td><s:textfield name="employee.trueName"></s:textfield></td>
				</tr>
				<tr>
					<td class="label">密码:</td>
					<td><s:password name="employee.password" showPassword="true"></s:password></td>
				</tr>
				<tr>
					<td class="label">部门</td>
					<!-- 部门要使用下拉列表 -->
					<td>
						<s:select 
						id="employee.department.id"
						name="employee.department.id" 
						headerKey="-1"
						headerValue="请选择"
						list="#request.listDept"
						listKey="id"
						listValue="deparmenntName">
						</s:select>
					</td>
				</tr>
				<tr>
					<td class="label">电话</td>
					<td><s:textfield name="employee.tel"></s:textfield></td>
				</tr>
				<tr>
					<td class="label">邮箱</td>
					<td><s:textfield name="employee.eamil"></s:textfield></td>
				</tr>
			</table>
			<div class="button-div">
				<input type="button" value="确定 " onclick="changForm()" />
				<input type="reset" value="重置 " />
			</div>
		</form>
	</div>

	<div id="footer">
		共执行 3 个查询，用时 0.162348 秒，Gzip 已禁用，内存占用 2.266 MB<br /> 版权所有 &copy;
		2017-2020 郑州正信科技有限公司，并保留所有权利。
	</div>

</body>
</html>